GtkDialog: Be a little more careful about button placement
authorMatthias Clasen <mclasen@redhat.com>
Fri, 6 Jun 2014 17:00:06 +0000 (13:00 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 6 Jun 2014 17:00:06 +0000 (13:00 -0400)
We were applying response based heuristics, even if the button
is explicitly put in the headerbar. That broke button placement
in some epiphany dialogs, such as the Cookies one. Therefore,
restrict the heuristics to action widgets that are added through
gtk_widget_add_action_widget() or <child type="action">, where it
is not possible to specify placement explicitly.

gtk/gtkdialog.c

index a97282bc33cd71a37e5b61c2620060c9dbbd0c6b..4ab47fb4abfc97322b6c3bbfea43d21f42fdbd4f 100644 (file)
@@ -1859,6 +1859,7 @@ gtk_dialog_buildable_custom_finished (GtkBuildable *buildable,
   for (l = parser_data->items; l; l = l->next)
     {
       ActionWidgetInfo *item = l->data;
+      gboolean is_action;
 
       object = gtk_builder_get_object (builder, item->widget_name);
       if (!object)
@@ -1869,6 +1870,14 @@ gtk_dialog_buildable_custom_finished (GtkBuildable *buildable,
          continue;
        }
 
+      /* If the widget already has reponse data at this point, it
+       * was either added by gtk_dialog_add_action_widget(), or via
+       * <child type="action"> or by moving an action area child
+       * to the header bar. In these cases, apply placement heuristics
+       * based on the response id.
+       */
+      is_action = get_response_data (GTK_WIDGET (object), FALSE) != NULL;
+
       ad = get_response_data (GTK_WIDGET (object), TRUE);
       ad->response_id = item->response_id;
 
@@ -1886,10 +1895,13 @@ gtk_dialog_buildable_custom_finished (GtkBuildable *buildable,
          g_signal_connect_closure_by_id (object, signal_id, 0, closure, FALSE);
        }
 
-      if (GTK_IS_HEADER_BAR (gtk_widget_get_parent (GTK_WIDGET (object))))
-        apply_response_for_header_bar (dialog, GTK_WIDGET (object), ad->response_id);
-      else
-        apply_response_for_action_area (dialog, GTK_WIDGET (object), ad->response_id);
+      if (is_action)
+        {
+          if (GTK_IS_HEADER_BAR (gtk_widget_get_parent (GTK_WIDGET (object))))
+            apply_response_for_header_bar (dialog, GTK_WIDGET (object), ad->response_id);
+          else
+            apply_response_for_action_area (dialog, GTK_WIDGET (object), ad->response_id);
+        }
 
       if (item->is_default)
         gtk_widget_grab_default (GTK_WIDGET (object));